package com.chb.controller;


import com.chb.common.ResultCode;
import com.chb.dto.ResultDto;
import com.chb.service.SeckillGoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 秒杀商品表 前端控制器
 * </p>
 *
 * @author CHB
 * @since 2022-08-23 15:58:28
 */
@RestController
@RequestMapping("/seckillGoods")
public class SeckillGoodsController {

    @Resource
    private SeckillGoodsService seckillGoodsService;

    /**
     *
     * @param goodsId 商品id
     * @author CHB
     * @date 2022-08-23 16:17:12
     * @return ResultDto<String>
     */
    @GetMapping("/seckill")
    public ResultDto<String> seckillGoods(Long goodsId){
        String result = seckillGoodsService.seckillGoods(goodsId);
        if(!"success".equals(result)){
            return ResultDto.error(ResultCode.ERROR.getCode(),result);
        }
        return ResultDto.success();
    }
}
